{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd \n",
    "import numpy as np \n",
    "import seaborn as sns \n",
    "import matplotlib.pyplot as plt \n",
    "from scipy.stats import skew "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 179,
   "metadata": {},
   "outputs": [],
   "source": [
    "train = pd.read_csv('happiness_train_complete.csv', encoding='gbk')\n",
    "test = pd.read_csv('happiness_test_complete.csv', encoding='gbk')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 180,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>happiness</th>\n",
       "      <th>survey_type</th>\n",
       "      <th>province</th>\n",
       "      <th>city</th>\n",
       "      <th>county</th>\n",
       "      <th>survey_time</th>\n",
       "      <th>gender</th>\n",
       "      <th>birth</th>\n",
       "      <th>nationality</th>\n",
       "      <th>religion</th>\n",
       "      <th>religion_freq</th>\n",
       "      <th>edu</th>\n",
       "      <th>edu_other</th>\n",
       "      <th>edu_status</th>\n",
       "      <th>edu_yr</th>\n",
       "      <th>income</th>\n",
       "      <th>political</th>\n",
       "      <th>join_party</th>\n",
       "      <th>floor_area</th>\n",
       "      <th>property_0</th>\n",
       "      <th>property_1</th>\n",
       "      <th>property_2</th>\n",
       "      <th>property_3</th>\n",
       "      <th>property_4</th>\n",
       "      <th>property_5</th>\n",
       "      <th>property_6</th>\n",
       "      <th>property_7</th>\n",
       "      <th>property_8</th>\n",
       "      <th>property_other</th>\n",
       "      <th>height_cm</th>\n",
       "      <th>weight_jin</th>\n",
       "      <th>health</th>\n",
       "      <th>health_problem</th>\n",
       "      <th>depression</th>\n",
       "      <th>hukou</th>\n",
       "      <th>hukou_loc</th>\n",
       "      <th>media_1</th>\n",
       "      <th>media_2</th>\n",
       "      <th>media_3</th>\n",
       "      <th>media_4</th>\n",
       "      <th>media_5</th>\n",
       "      <th>media_6</th>\n",
       "      <th>leisure_1</th>\n",
       "      <th>leisure_2</th>\n",
       "      <th>leisure_3</th>\n",
       "      <th>leisure_4</th>\n",
       "      <th>leisure_5</th>\n",
       "      <th>leisure_6</th>\n",
       "      <th>leisure_7</th>\n",
       "      <th>leisure_8</th>\n",
       "      <th>leisure_9</th>\n",
       "      <th>leisure_10</th>\n",
       "      <th>leisure_11</th>\n",
       "      <th>leisure_12</th>\n",
       "      <th>socialize</th>\n",
       "      <th>relax</th>\n",
       "      <th>learn</th>\n",
       "      <th>social_neighbor</th>\n",
       "      <th>social_friend</th>\n",
       "      <th>socia_outing</th>\n",
       "      <th>equity</th>\n",
       "      <th>class</th>\n",
       "      <th>class_10_before</th>\n",
       "      <th>class_10_after</th>\n",
       "      <th>class_14</th>\n",
       "      <th>work_exper</th>\n",
       "      <th>work_status</th>\n",
       "      <th>work_yr</th>\n",
       "      <th>work_type</th>\n",
       "      <th>work_manage</th>\n",
       "      <th>insur_1</th>\n",
       "      <th>insur_2</th>\n",
       "      <th>insur_3</th>\n",
       "      <th>insur_4</th>\n",
       "      <th>family_income</th>\n",
       "      <th>family_m</th>\n",
       "      <th>family_status</th>\n",
       "      <th>house</th>\n",
       "      <th>car</th>\n",
       "      <th>invest_0</th>\n",
       "      <th>invest_1</th>\n",
       "      <th>invest_2</th>\n",
       "      <th>invest_3</th>\n",
       "      <th>invest_4</th>\n",
       "      <th>invest_5</th>\n",
       "      <th>invest_6</th>\n",
       "      <th>invest_7</th>\n",
       "      <th>invest_8</th>\n",
       "      <th>invest_other</th>\n",
       "      <th>son</th>\n",
       "      <th>daughter</th>\n",
       "      <th>minor_child</th>\n",
       "      <th>marital</th>\n",
       "      <th>marital_1st</th>\n",
       "      <th>s_birth</th>\n",
       "      <th>marital_now</th>\n",
       "      <th>s_edu</th>\n",
       "      <th>s_political</th>\n",
       "      <th>s_hukou</th>\n",
       "      <th>s_income</th>\n",
       "      <th>s_work_exper</th>\n",
       "      <th>s_work_status</th>\n",
       "      <th>s_work_type</th>\n",
       "      <th>f_birth</th>\n",
       "      <th>f_edu</th>\n",
       "      <th>f_political</th>\n",
       "      <th>f_work_14</th>\n",
       "      <th>m_birth</th>\n",
       "      <th>m_edu</th>\n",
       "      <th>m_political</th>\n",
       "      <th>m_work_14</th>\n",
       "      <th>status_peer</th>\n",
       "      <th>status_3_before</th>\n",
       "      <th>view</th>\n",
       "      <th>inc_ability</th>\n",
       "      <th>inc_exp</th>\n",
       "      <th>trust_1</th>\n",
       "      <th>trust_2</th>\n",
       "      <th>trust_3</th>\n",
       "      <th>trust_4</th>\n",
       "      <th>trust_5</th>\n",
       "      <th>trust_6</th>\n",
       "      <th>trust_7</th>\n",
       "      <th>trust_8</th>\n",
       "      <th>trust_9</th>\n",
       "      <th>trust_10</th>\n",
       "      <th>trust_11</th>\n",
       "      <th>trust_12</th>\n",
       "      <th>trust_13</th>\n",
       "      <th>neighbor_familiarity</th>\n",
       "      <th>public_service_1</th>\n",
       "      <th>public_service_2</th>\n",
       "      <th>public_service_3</th>\n",
       "      <th>public_service_4</th>\n",
       "      <th>public_service_5</th>\n",
       "      <th>public_service_6</th>\n",
       "      <th>public_service_7</th>\n",
       "      <th>public_service_8</th>\n",
       "      <th>public_service_9</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>12</td>\n",
       "      <td>32</td>\n",
       "      <td>59</td>\n",
       "      <td>2015/8/4 14:18</td>\n",
       "      <td>1</td>\n",
       "      <td>1959</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>11</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>-2.0</td>\n",
       "      <td>20000</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>45.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>176</td>\n",
       "      <td>155</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>2.0</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>3.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>3.0</td>\n",
       "      <td>30.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>60000.0</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3</td>\n",
       "      <td>1984.0</td>\n",
       "      <td>1958.0</td>\n",
       "      <td>1984.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>40000.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-2</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>-2</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>50000.0</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>-8</td>\n",
       "      <td>-8</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>-8</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>50</td>\n",
       "      <td>60</td>\n",
       "      <td>50</td>\n",
       "      <td>50</td>\n",
       "      <td>30.0</td>\n",
       "      <td>30</td>\n",
       "      <td>50</td>\n",
       "      <td>50</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>18</td>\n",
       "      <td>52</td>\n",
       "      <td>85</td>\n",
       "      <td>2015/7/21 15:04</td>\n",
       "      <td>1</td>\n",
       "      <td>1992</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>12</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>2013.0</td>\n",
       "      <td>20000</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>110.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>170</td>\n",
       "      <td>110</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>6.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "      <td>4</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>3.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>40000.0</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1972</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>1973</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>50000.0</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>90</td>\n",
       "      <td>70</td>\n",
       "      <td>70</td>\n",
       "      <td>80</td>\n",
       "      <td>85.0</td>\n",
       "      <td>70</td>\n",
       "      <td>90</td>\n",
       "      <td>60</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>29</td>\n",
       "      <td>83</td>\n",
       "      <td>126</td>\n",
       "      <td>2015/7/21 13:24</td>\n",
       "      <td>2</td>\n",
       "      <td>1967</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>-2.0</td>\n",
       "      <td>2000</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>120.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>160</td>\n",
       "      <td>122</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>2.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>8000.0</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3</td>\n",
       "      <td>1990.0</td>\n",
       "      <td>1968.0</td>\n",
       "      <td>1990.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>6000.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>-2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>80000.0</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>-8</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>90</td>\n",
       "      <td>80</td>\n",
       "      <td>75</td>\n",
       "      <td>79</td>\n",
       "      <td>80.0</td>\n",
       "      <td>90</td>\n",
       "      <td>90</td>\n",
       "      <td>90</td>\n",
       "      <td>75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>10</td>\n",
       "      <td>28</td>\n",
       "      <td>51</td>\n",
       "      <td>2015/7/25 17:33</td>\n",
       "      <td>2</td>\n",
       "      <td>1943</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1959.0</td>\n",
       "      <td>6420</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>78.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>163</td>\n",
       "      <td>170</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>1.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>12000.0</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7</td>\n",
       "      <td>1960.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-2</td>\n",
       "      <td>14</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>-2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>10000.0</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>100</td>\n",
       "      <td>90</td>\n",
       "      <td>70</td>\n",
       "      <td>80</td>\n",
       "      <td>80.0</td>\n",
       "      <td>90</td>\n",
       "      <td>90</td>\n",
       "      <td>80</td>\n",
       "      <td>80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>18</td>\n",
       "      <td>36</td>\n",
       "      <td>2015/8/10 9:50</td>\n",
       "      <td>2</td>\n",
       "      <td>1994</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>12</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2014.0</td>\n",
       "      <td>-1</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>70.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>165</td>\n",
       "      <td>110</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>7.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>-2.0</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1970</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>10</td>\n",
       "      <td>1972</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>15</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>-8</td>\n",
       "      <td>200000.0</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>50</td>\n",
       "      <td>50</td>\n",
       "      <td>50</td>\n",
       "      <td>50</td>\n",
       "      <td>50.0</td>\n",
       "      <td>50</td>\n",
       "      <td>50</td>\n",
       "      <td>50</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id  happiness  survey_type  province  city  county      survey_time  \\\n",
       "0   1          4            1        12    32      59   2015/8/4 14:18   \n",
       "1   2          4            2        18    52      85  2015/7/21 15:04   \n",
       "2   3          4            2        29    83     126  2015/7/21 13:24   \n",
       "3   4          5            2        10    28      51  2015/7/25 17:33   \n",
       "4   5          4            1         7    18      36   2015/8/10 9:50   \n",
       "\n",
       "   gender  birth  nationality  religion  religion_freq  edu edu_other  \\\n",
       "0       1   1959            1         1              1   11       NaN   \n",
       "1       1   1992            1         1              1   12       NaN   \n",
       "2       2   1967            1         0              3    4       NaN   \n",
       "3       2   1943            1         1              1    3       NaN   \n",
       "4       2   1994            1         1              1   12       NaN   \n",
       "\n",
       "   edu_status  edu_yr  income  political  join_party  floor_area  property_0  \\\n",
       "0         4.0    -2.0   20000          1         NaN        45.0           0   \n",
       "1         4.0  2013.0   20000          1         NaN       110.0           0   \n",
       "2         4.0    -2.0    2000          1         NaN       120.0           0   \n",
       "3         4.0  1959.0    6420          1         NaN        78.0           0   \n",
       "4         1.0  2014.0      -1          2         NaN        70.0           0   \n",
       "\n",
       "   property_1  property_2  property_3  property_4  property_5  property_6  \\\n",
       "0           1           0           0           0           0           0   \n",
       "1           0           0           0           1           0           0   \n",
       "2           1           1           0           0           0           0   \n",
       "3           0           0           1           0           0           0   \n",
       "4           0           0           0           1           0           0   \n",
       "\n",
       "   property_7  property_8 property_other  height_cm  weight_jin  health  \\\n",
       "0           0           0            NaN        176         155       3   \n",
       "1           0           0            NaN        170         110       5   \n",
       "2           0           0            NaN        160         122       4   \n",
       "3           0           0            NaN        163         170       4   \n",
       "4           0           0            NaN        165         110       5   \n",
       "\n",
       "   health_problem  depression  hukou  hukou_loc  media_1  media_2  media_3  \\\n",
       "0               2           5      5        2.0        4        2        5   \n",
       "1               4           3      1        1.0        2        2        1   \n",
       "2               4           5      1        1.0        2        2        2   \n",
       "3               4           4      1        2.0        2        1        1   \n",
       "4               5           3      2        3.0        1        3        4   \n",
       "\n",
       "   media_4  media_5  media_6  leisure_1  leisure_2  leisure_3  leisure_4  \\\n",
       "0        5        4        3          1          4          3          1   \n",
       "1        3        5        1          2          3          4          3   \n",
       "2        5        1        3          1          4          4          3   \n",
       "3        5        1        1          1          5          2          4   \n",
       "4        2        5        5          3          3          3          2   \n",
       "\n",
       "   leisure_5  leisure_6  leisure_7  leisure_8  leisure_9  leisure_10  \\\n",
       "0          2          3          4          1          4           5   \n",
       "1          5          4          3          2          3           4   \n",
       "2          5          4          4          2          3           5   \n",
       "3          5          4          5          1          1           5   \n",
       "4          4          4          3          5          2           5   \n",
       "\n",
       "   leisure_11  leisure_12  socialize  relax  learn  social_neighbor  \\\n",
       "0           4           1          2      4      3              3.0   \n",
       "1           5           1          2      4      3              6.0   \n",
       "2           5           5          3      4      2              2.0   \n",
       "3           5           5          2      4      4              1.0   \n",
       "4           5           1          4      3      4              7.0   \n",
       "\n",
       "   social_friend  socia_outing  equity  class  class_10_before  \\\n",
       "0            3.0             2       3      3                3   \n",
       "1            2.0             1       3      6                4   \n",
       "2            5.0             2       4      5                4   \n",
       "3            6.0             1       4      5                5   \n",
       "4            5.0             3       2      1                1   \n",
       "\n",
       "   class_10_after  class_14  work_exper  work_status  work_yr  work_type  \\\n",
       "0               3         1           1          3.0     30.0        1.0   \n",
       "1               8         5           1          3.0      2.0        1.0   \n",
       "2               6         3           2          NaN      NaN        NaN   \n",
       "3               7         2           4          NaN      NaN        NaN   \n",
       "4               1         4           6          NaN      NaN        NaN   \n",
       "\n",
       "   work_manage  insur_1  insur_2  insur_3  insur_4  family_income  family_m  \\\n",
       "0          2.0        1        1        1        2        60000.0         2   \n",
       "1          3.0        1        1        1        1        40000.0         3   \n",
       "2          NaN        1        1        2        2         8000.0         3   \n",
       "3          NaN        2        2        2        2        12000.0         3   \n",
       "4          NaN        1        2        2        2           -2.0         4   \n",
       "\n",
       "   family_status  house  car  invest_0  invest_1  invest_2  invest_3  \\\n",
       "0              2      1    2         0         1         0         0   \n",
       "1              4      1    2         0         1         0         0   \n",
       "2              3      1    2         0         1         0         0   \n",
       "3              3      1    1         0         1         0         0   \n",
       "4              3      1    1         0         1         0         0   \n",
       "\n",
       "   invest_4  invest_5  invest_6  invest_7  invest_8 invest_other  son  \\\n",
       "0         0         0         0         0         0          NaN    1   \n",
       "1         0         0         0         0         0          NaN    0   \n",
       "2         0         0         0         0         0          NaN    0   \n",
       "3         0         0         0         0         0          NaN    1   \n",
       "4         0         0         0         0         0          NaN    0   \n",
       "\n",
       "   daughter  minor_child  marital  marital_1st  s_birth  marital_now  s_edu  \\\n",
       "0         0          0.0        3       1984.0   1958.0       1984.0    6.0   \n",
       "1         0          NaN        1          NaN      NaN          NaN    NaN   \n",
       "2         2          1.0        3       1990.0   1968.0       1990.0    3.0   \n",
       "3         4          0.0        7       1960.0      NaN          NaN    NaN   \n",
       "4         0          NaN        1          NaN      NaN          NaN    NaN   \n",
       "\n",
       "   s_political  s_hukou  s_income  s_work_exper  s_work_status  s_work_type  \\\n",
       "0          1.0      5.0   40000.0           5.0            NaN          NaN   \n",
       "1          NaN      NaN       NaN           NaN            NaN          NaN   \n",
       "2          1.0      1.0    6000.0           3.0            NaN          NaN   \n",
       "3          NaN      NaN       NaN           NaN            NaN          NaN   \n",
       "4          NaN      NaN       NaN           NaN            NaN          NaN   \n",
       "\n",
       "   f_birth  f_edu  f_political  f_work_14  m_birth  m_edu  m_political  \\\n",
       "0       -2      4            4          1       -2      4            1   \n",
       "1     1972      3            1          2     1973      3            1   \n",
       "2       -2      1            1          2       -2      1            1   \n",
       "3       -2     14            1          2       -2      1            1   \n",
       "4     1970      6            1         10     1972      4            1   \n",
       "\n",
       "   m_work_14  status_peer  status_3_before  view  inc_ability   inc_exp  \\\n",
       "0          1            3                2     4            3   50000.0   \n",
       "1          2            1                1     4            2   50000.0   \n",
       "2          2            2                1     4            2   80000.0   \n",
       "3          2            2                1     3            2   10000.0   \n",
       "4         15            3                2     3           -8  200000.0   \n",
       "\n",
       "   trust_1  trust_2  trust_3  trust_4  trust_5  trust_6  trust_7  trust_8  \\\n",
       "0        4        2       -8       -8        5        3        2        3   \n",
       "1        5        4        4        3        5        3        3        3   \n",
       "2        3        3        3        3        4        3        3        3   \n",
       "3        3        3        4        3        5        3        3        5   \n",
       "4        4        3        3        3        5        5        3        4   \n",
       "\n",
       "   trust_9  trust_10  trust_11  trust_12  trust_13  neighbor_familiarity  \\\n",
       "0        4         3        -8         4         1                     4   \n",
       "1        2         3         3         3         2                     3   \n",
       "2        3         3        -8         3         1                     4   \n",
       "3        4         3         3         3         2                     3   \n",
       "4        3         3         3         3         2                     2   \n",
       "\n",
       "   public_service_1  public_service_2  public_service_3  public_service_4  \\\n",
       "0                50                60                50                50   \n",
       "1                90                70                70                80   \n",
       "2                90                80                75                79   \n",
       "3               100                90                70                80   \n",
       "4                50                50                50                50   \n",
       "\n",
       "   public_service_5  public_service_6  public_service_7  public_service_8  \\\n",
       "0              30.0                30                50                50   \n",
       "1              85.0                70                90                60   \n",
       "2              80.0                90                90                90   \n",
       "3              80.0                90                90                80   \n",
       "4              50.0                50                50                50   \n",
       "\n",
       "   public_service_9  \n",
       "0                50  \n",
       "1                60  \n",
       "2                75  \n",
       "3                80  \n",
       "4                50  "
      ]
     },
     "execution_count": 180,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 202,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.concat((train, test))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 203,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "happiness      1.000000\n",
       "depression     0.299933\n",
       "class          0.267328\n",
       "health         0.246979\n",
       "equity         0.245552\n",
       "                 ...   \n",
       "leisure_8     -0.059650\n",
       "property_0    -0.080732\n",
       "status_peer   -0.084743\n",
       "leisure_9     -0.106339\n",
       "invest_6            NaN\n",
       "Name: happiness, Length: 136, dtype: float64"
      ]
     },
     "execution_count": 203,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.corr()['happiness'].sort_values(ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 204,
   "metadata": {},
   "outputs": [],
   "source": [
    "del_cols = ['id', 'happiness', 'survey_time']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 205,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.drop(del_cols, axis=1, inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 206,
   "metadata": {},
   "outputs": [],
   "source": [
    "num_to_str = ['survey_type', 'province', 'city', 'county', 'gender', 'nationality', 'religion',\n",
    "              'edu', 'edu_status', 'political', 'join_party','health', 'health_problem', 'depression', 'hukou',\n",
    "             'hukou_loc', 'socialize', 'relax','learn', 'social_neighbor', 'social_friend', 'socia_outing', 'equity', 'class',\n",
    "             'class_10_before', 'class_10_after', 'class_14', 'work_exper', 'work_status', 'work_yr', 'work_type',\n",
    "             'work_manage', 'family_status', 's_edu', 's_political', 's_hukou', 's_work_exper', 's_work_status', 's_work_type',\n",
    "             'f_edu', 'f_political', 'f_work_14', 'm_edu', 'm_political', 'm_work_14', 'status_peer', 'status_3_before',\n",
    "             'view', 'neighbor_familiarity']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 207,
   "metadata": {},
   "outputs": [],
   "source": [
    "for col in num_to_str:\n",
    "    df[col] = df[col].fillna('None')\n",
    "    df[col] = df[col].apply(str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 208,
   "metadata": {},
   "outputs": [],
   "source": [
    "year_cols = ['birth', 'edu_yr', 'work_yr', 'marital_1st', 'marital_now', 'f_birth', 'm_birth']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 209,
   "metadata": {},
   "outputs": [],
   "source": [
    "for col in year_cols:\n",
    "    df[col] = df[col].fillna('None')\n",
    "    df[col] = df[col].apply(str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 210,
   "metadata": {},
   "outputs": [],
   "source": [
    "other = ['edu_other', 'property_other', 'invest_other']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 211,
   "metadata": {},
   "outputs": [],
   "source": [
    "for col in other:\n",
    "    df[col] = df[col].fillna('None')\n",
    "    df[col] = df[col].apply(lambda x: x if x=='None' else '1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 214,
   "metadata": {},
   "outputs": [],
   "source": [
    "num = ['religion_freq', 'income', 'floor_area', 'height_cm', 'weight_jin','family_income', 'family_m', 'house', 'car',\n",
    "       'son', 'daughter', 'marital', 's_income', 'inc_ability']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 223,
   "metadata": {},
   "outputs": [],
   "source": [
    "for col in num:\n",
    "    df[col] = df[col].apply(lambda x: 0 if x<0 else x)\n",
    "    df[col] = df[col].fillna(0)\n",
    "    if df[col].skew() > 1:\n",
    "        df[col] = df[col].apply(np.log1p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "'property_0'- 'property_8'\n",
    "'media_1' - 'media_6'\n",
    "'leisure_1' - 'leisure_12'\n",
    "'insur_1 - insur_4'\n",
    "'invest_1' - 'invest_8'\n",
    "'trust_1'- 'trust_13'\n",
    "'public_service_1' - 'public_service_9'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 227,
   "metadata": {},
   "outputs": [],
   "source": [
    "dum_cols = []\n",
    "for col in df.columns:\n",
    "    if ('property' in col) or 'media' in col or 'leisure' in col or 'insur' in col or 'invest' in col or 'trust' in col or 'public' in col:\n",
    "        dum_cols.append(col)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 235,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.get_dummies(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 245,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df.fillna(df.mean())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 246,
   "metadata": {},
   "outputs": [],
   "source": [
    "x_train = df[:len(train)]\n",
    "y = train['happiness']\n",
    "x_test = df[len(train):]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 247,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import Ridge, RidgeCV, ElasticNet, LassoCV, Lasso \n",
    "from sklearn.model_selection import cross_val_score \n",
    "import lightgbm as lgb\n",
    "\n",
    "def acc(model):\n",
    "    score = cross_val_score(model, x_train, y, scoring='accuracy', cv=5)\n",
    "    return score "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 264,
   "metadata": {},
   "outputs": [],
   "source": [
    "lgr = lgb.LGBMClassifier(objective='Regressor',\n",
    "                         num_leaves=20,\n",
    "                         min_data_in_leaf=20,\n",
    "                         max_depth=6,\n",
    "                         learning_rate=0.01,\n",
    "                         min_child_samples=30,\n",
    "                         feature_fraction=0.8,\n",
    "                         bagging_freq=1,\n",
    "                         bagging_fraction=0.8,\n",
    "                         bagging_seed=11,\n",
    "#                          metric='mse',\n",
    "                         lambda_l1=0.1,\n",
    "                         n_estimators=1000,\n",
    "                       )\n",
    "score = acc(lgr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 265,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.635    0.63625  0.625    0.630625 0.6275  ]\n"
     ]
    }
   ],
   "source": [
    "print(score)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 257,
   "metadata": {},
   "outputs": [],
   "source": [
    "lgr = lgr.fit(x_train, y)\n",
    "pred = lgr.predict(x_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 258,
   "metadata": {},
   "outputs": [],
   "source": [
    "sub = pd.DataFrame()\n",
    "sub[id] = test.id \n",
    "sub['happiness'] = pred\n",
    "sub.to_csv('submission_2020_03_07.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "'boosting_type': 'gbdt',\n",
    "         'num_leaves': 20,\n",
    "         'min_data_in_leaf': 20, \n",
    "         'objective':'regression',\n",
    "         'max_depth':6,\n",
    "         'learning_rate': 0.01,\n",
    "         \"min_child_samples\": 30,\n",
    "         \"feature_fraction\": 0.8,\n",
    "         \"bagging_freq\": 1,\n",
    "         \"bagging_fraction\": 0.8 ,\n",
    "         \"bagging_seed\": 11,\n",
    "         \"metric\": 'mse',\n",
    "         \"lambda_l1\": 0.1,\n",
    "         \"verbosity\": -1"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
